<template>
  <div class="app-container">
    <input type="hidden" v-model="information.id"/>
    <el-form ref="form" :model="information" label-width="120px">
      <el-form-item label="标题">
        <el-input v-model="information.informationTitle"/>
      </el-form-item>
      <el-form-item label="信息分类">
        <el-input v-model="information.informationType"/>
      </el-form-item>
      <el-form-item label="紧急程度">
        <el-input v-model="information.urgency"/>
      </el-form-item>
      <el-form-item label="内容格式">
        <el-input v-model="information.contentFormat"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">更新信息</el-button>
        <el-button @click="onCancel">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>


<script>
import request from '@/utils/request'

export default {
  data() {
    return {
      information: {
        id: 0,
        informationTitle: '',
        informationType: '',
        urgency: '',
        contentFormat: ''
      }

    }
  },
  mounted() {
    this.information = this.$route.query.data;
  },
  methods: {
    onSubmit() {
      // 请求接口 实现用户新增接口的调用
      console.log("information")
      console.log(this.information)
      request({
        url: "http://127.0.0.1:8080/api/information/update.do",
        method: "POST",
        data: this.information
      }).then(res => {
        if (res.code == 0) {
          //跳转到列表页面
          this.$router.push("/informationlist");
        }
      })
    },
    onCancel() {
      this.$message({
        message: 'cancel!',
        type: 'warning'
      })
    }
  }
}
</script>

<style scoped>
.line {
  text-align: center;
}
</style>

